package com.xxx.video.mine.presenters;

import android.content.Context;

import androidx.annotation.NonNull;

import com.xxx.video.commen.beans.BaseBean;
import com.xxx.video.commen.presenters.BasePresenter;
import com.xxx.video.commen.utils.ResponseUtils;
import com.xxx.video.mine.beans.FavoriteListBean;
import com.xxx.video.network.listeners.CommonResponseListener;
import com.xxx.video.network.utils.NetWorkUtils;

public class FavoritesPresenter extends BasePresenter<IFavoritesView> {
    public FavoritesPresenter(@NonNull Context context, IFavoritesView baseView) {
        super(context, baseView);
    }

    public void collectionList(int page) {
        NetWorkUtils.getInstance().collectionList(page, new CommonResponseListener<FavoriteListBean>() {

            @Override
            public void onSuccess(FavoriteListBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().initData2View(successOb);
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {
                if (getBaseView() != null) {
                    getBaseView().showRootLayoutStatus(3);
                }
            }
        });
    }
    public void deleteCollection(String fId, int position) {
        NetWorkUtils.getInstance().deleteCollection(fId, new CommonResponseListener<BaseBean>() {

            @Override
            public void onSuccess(BaseBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().unCollectionSuccess(position);
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {

            }
        });
    }

}
